/*
 * GoogleReader.h
 *
 *  Created on: May 13, 2011
 *      Author: ToanNhan
 */

#ifndef GoogleReader_H_
#define GoogleReader_H_

#include <FText.h>
#include "Downloader.h"
#include <FBase.h>
#include <FIo.h>
#include <FMedia.h>
#include <FBaseByteBuffer.h>
#include "ITextReader.h"

using namespace Osp::Base::Runtime;
using namespace Osp::Media;
using namespace Osp::Graphics;
using namespace Osp::Base;
using namespace Osp::Base::Collection;
using namespace Osp::Io;
using namespace Osp::Text;

class GoogleReader: public ITextReader,
					public IDownloadFinishedListener,
					public IPlayerEventListener
{
private:
	bool isReadSingleText;
	Downloader *pDownloader;
	Player* pPlayer;
	BufferInfo bufferInfoforVideo;

	void talk();
	void talk(String pathOfFile);
	String urlPattern;

	String currentLanguage;
public:
	//language code
	static const int ENGLISH = 0;
	static const int VIETNAMESE = 1;

	void SetLanguage(int languageCode);
	//Define language


	GoogleReader();
	virtual ~GoogleReader();

	void OnDataDownloadComplete(int statusCode, ByteBuffer *buffer){}
	void OnDownloadComplete(Osp::Base::String url, Osp::Base::String path);
	void OnDataDownloadComplete(Osp::Base::ByteBuffer *buffer);
	void OnDownloadFailed(Osp::Base::String url, Osp::Base::String path);
	void OnPlayerOpened(result r);
	void OnPlayerEndOfClip(void);
	void OnPlayerBuffering(int percent);
	void OnPlayerErrorOccurred(Osp::Media::PlayerErrorReason r);
	void OnPlayerInterrupted(void);
	void OnPlayerReleased(void);

	result readText();
	result readText(String text);
};

#endif /* GoogleReader_H_ */
